package com.atguigu.gmall.product.mapper;

import com.atguigu.gmall.model.product.BaseAttrInfo;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @description 属性表Mapper
 * @author 李旭
 * @date 2021-03-31
 */
public interface BaseAttrInfoMapper extends BaseMapper<BaseAttrInfo> {

    //根据分类查询平台属性及属性值  Mybatis 为什么要学习Mybatis？  Sql与Java解耦
    //@Select("")
    List<BaseAttrInfo> attrInfoList(
            @Param("category1Id") Long category1Id,
            @Param("category2Id") Long category2Id,
            @Param("category3Id") Long category3Id);

/*    @Select(
    "<script>select t0.* from base_attr_info t0 " +
    //add here if need left join
    "where 1=1" +
    "<when test='id!=null and id!=&apos;&apos; '> and t0.id=#{id}</when> " +
    "<when test='attrName!=null and attrName!=&apos;&apos; '> and t0.attr_name=#{attrName}</when> " +
    "<when test='categoryId!=null and categoryId!=&apos;&apos; '> and t0.category_id=#{categoryId}</when> " +
    "<when test='categoryLevel!=null and categoryLevel!=&apos;&apos; '> and t0.category_level=#{categoryLevel}</when> " +
    //add here if need page limit
    //" limit ${page},${limit} " +
    " </script>")
    List<BaseAttrInfo> pageAll(BaseAttrInfo queryParamDTO, int page, int limit);

    @Select("<script>select count(1) from base_attr_info t0 " +
    //add here if need left join
    "where 1=1" +
    "<when test='id!=null and id!=&apos;&apos; '> and t0.id=#{id}</when> " +
    "<when test='attrName!=null and attrName!=&apos;&apos; '> and t0.attr_name=#{attrName}</when> " +
    "<when test='categoryId!=null and categoryId!=&apos;&apos; '> and t0.category_id=#{categoryId}</when> " +
    "<when test='categoryLevel!=null and categoryLevel!=&apos;&apos; '> and t0.category_level=#{categoryLevel}</when> " +
     " </script>")
    int countAll(BaseAttrInfo queryParamDTO);*/

}